package com.ruoyi.depot.mapper;

import java.util.List;
import java.util.Map;

import com.ruoyi.depot.domain.WalmartStockPlan;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * walmart备货计划Mapper接口
 * 
 * @author ruoyi
 * @date 2025-02-26
 */
@Mapper
public interface WalmartStockPlanMapper
{
    /**
     * 查询walmart备货计划
     * 
     * @param stockId walmart备货计划主键
     * @return walmart备货计划
     */
    public WalmartStockPlan selectWalmartStockPlanByStockId(@Param("stockId") String stockId);

    /**
     * 查询walmart备货计划列表
     * 
     * @param walmartStockPlan walmart备货计划
     * @return walmart备货计划集合
     */
    public List<WalmartStockPlan> selectWalmartStockPlanList(@Param("Req") WalmartStockPlan walmartStockPlan,@Param("stockIds") List<String> stockIds);

    /**
     * 新增walmart备货计划
     * 
     * @param walmartStockPlan walmart备货计划
     * @return 结果
     */
    public int insertWalmartStockPlan(WalmartStockPlan walmartStockPlan);

    /**
     * 修改walmart备货计划
     * 
     * @param walmartStockPlan walmart备货计划
     * @return 结果
     */
    public int updateWalmartStockPlan(WalmartStockPlan walmartStockPlan);

    /**
     * 删除walmart备货计划
     * 
     * @param stockId walmart备货计划主键
     * @return 结果
     */
    public int deleteWalmartStockPlanByStockId(String stockId);

    /**
     * 批量删除walmart备货计划
     * 
     * @param stockIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteWalmartStockPlanByStockIds(String[] stockIds);

    /**
     * 获取最后一个备货单号
     * @return
     */
    String selectLastStockPlanNumberForUpdate(@Param("currentDate") String currentDate);

    /**
     * 检查备货单号是否已经存在
     * @param code
     * @return
     */
    int checkStockPlanNumberExists(@Param("code") String code);
    /**
     * 设置walmart备货计划关联ID
     * @return
     */
    int setWalmartStockPlanShipmentId(WalmartStockPlan walmartStockPlan);

    /**
     *  查询对应的备货计划状态
     * @param stockIds
     * @return
     */
    List<WalmartStockPlan> selectWalmartStockPlanStatus(@Param("list") String[] stockIds);


    /**
     * 修改备货计划状态为已发货
     * @param stockIds
     * @return
     */
    int updateStatus(@Param("stockIds") String[] stockIds);
    /**
     * 取消关联的备货计划的发货 shipmentId
     * @param shipmentId
     * @return
     */
    int updateWalmartStockPlanShipmentId(@Param("shipmentId")  String shipmentId);
    /**
     * 查询指定 authId 下所有非空的 shipment_id（去重）
     */
    List<String> selectDistinctShipmentIdsByAuthId(@Param("authId") Long authId);
    /**
     * 已取消的walmart入库单，清空备货计划的shipment_id
     */
    int clearWalmartStockPlanShipmentIdBatch(@Param("shipmentIds") List<String> shipmentIds);
    /**
     * 查询每个 stock_id 对应的状态
     */
    @MapKey("stock_id")
    List<Map<String, String>> selectStockStatuses(@Param("stockIds") List<String> stockIds);
    /**
     * 查询每个 sku 对应的状态
     */
    @MapKey("stock_id")
    List<Map<String, String>> selectStockSkuStatuses(@Param("stockIds") List<String> stockIds);

    /**
     * 修改物流公司
     * @param walmartStockPlan
     * @return
     */
    int updateStockPlanLogistics(WalmartStockPlan walmartStockPlan);

    /**
     * 修改体积计算模式
     * @param walmartStockPlan
     * @return
     */
    int updateStockPlanVolumeMode(WalmartStockPlan walmartStockPlan);

    /**
     * @param freightValidationLog
     */
	int updateFreightValidationLog(@Param("info") String freightValidationLog, @Param("stockId") String stockId);

    /**
     * 查询是否选择了计算模式
     * @param stockIds
     * @return
     */
    List<WalmartStockPlan> selectVolumeMode(@Param("stockIds") String[] stockIds);

    /**
     * 修改快递单号
     * @param walmartStockPlan
     * @return
     */
	int updateStockTrackingNumber(WalmartStockPlan walmartStockPlan);
}
